package cn.wubo.vrr.help.service.impl;

import cn.wubo.vrr.help.entity.Person;
import cn.wubo.vrr.help.repository.PersonRepository;
import cn.wubo.vrr.help.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {
    @Autowired
    PersonRepository personRepository;

    @Override
    public List<Person> findAll() {
        return personRepository.findAll();
    }

    @Override
    public Person save(Person p) {
        return personRepository.save(p);
    }

    @Override
    public Integer deleteById(Integer id) {
        if(personRepository.existsById(id)){
            personRepository.deleteById(id);
            return 1;
        }else{
            return 0;
        }
    }
}
